package com.huawei.updatesdk.service.d.a;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.text.TextUtils;

public final class a {
    private static final String a = a.class.getSimpleName();
    private static String b = null;

    private a() {
    }

    public static String a() {
        if (b != null) {
            return b;
        }
        try {
            String packageName = com.huawei.updatesdk.a.b.a.a.a().b().getPackageName();
            PackageInfo packageInfo = com.huawei.updatesdk.a.b.a.a.a().b().getPackageManager().getPackageInfo(com.huawei.updatesdk.a.b.a.a.a().b().getPackageName(), 0);
            String str = packageInfo != null ? packageName + packageInfo.versionName : packageName;
            packageName = Build.BRAND;
            String str2 = "other";
            if (TextUtils.isEmpty(packageName)) {
                packageName = str2;
            }
            a(str + "_" + packageName);
            return b;
        } catch (NameNotFoundException e) {
            com.huawei.updatesdk.a.a.b.a.a.a.d(a, "getUserAgent() " + e.toString());
            return null;
        }
    }

    private static void a(String str) {
        b = str;
    }
}
